package com.tunan.system.dic.error.main;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;

import com.exception.AbstractMainError;
import com.exception.SubError;
import com.tunan.system.dic.error.sub.DeleteLockedItemSubError;
import com.tunan.system.dic.error.sub.DeleteLockedTypeSubError;

public class DeleteTypeError extends AbstractMainError {

	private static final long serialVersionUID = 1L;
	
	private static final String CODE = "101";
	private static final String MESSAGE = "删除字典类型出错";
	private static final String SOLUTION = "1、不能删除已锁定字典类型，需要手工解锁才能执行删除操作；2、不能删除包含已锁定字典子项的字典类型";
	
    
    public DeleteTypeError(String typeCode, String typeName) {
    	super(CODE, MESSAGE, SOLUTION);
    	setSubErrors(typeCode, typeName);
    }
    
    public DeleteTypeError(String typeCode, String typeName, String itemCode, String itemName) {
    	super(CODE, MESSAGE, SOLUTION);
    	setSubErrors(typeCode, typeName, itemCode, itemName);
    }

    private void setSubErrors(String typeCode, String typeName){
    	ArrayList<SubError> subErrors = new ArrayList<SubError>();
    	subErrors.add(new DeleteLockedTypeSubError(typeCode, typeName));
    	setSubErrors(subErrors);
    }
    
    private void setSubErrors(String typeCode, String typeName, String itemCode, String itemName){
    	ArrayList<SubError> subErrors = new ArrayList<SubError>();
    	subErrors.add(new DeleteLockedItemSubError(typeCode, typeName, itemCode, itemName));
    	setSubErrors(subErrors);
    }
}

